
<!DOCTYPE html>
<html>
<head>
<title>问 题</title>
<meta charset="utf-8" >
<meta name="renderer" content="webkit">
<meta name="author" content="XYB" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="format-detection" content="telphone=no, email=no"/>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="viewport" content="initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no">
<link rel="stylesheet" href="../../static/css/bootstrap.min.css">
<link rel="stylesheet" href="../../static/css/paging.min.css">
<link rel="stylesheet" href="../../static/css/init.css">
<link rel="stylesheet" href="../../static/css/common.css">
<link rel="stylesheet" href="../../static/css/faq/faq.css">
<link rel="icon" href="../../static/images/favicon.ico" type="image/x-icon">
<style>
.problem-area{
	padding:10px 10px 120px 10px;
}
.problem-tables{
	width:96%;
	margin-left:auto;
	margin-right:auto;
	border:1px solid #333;
}
.problem-tables thead tr{
	background: #d9edf7;
}
.problem-tables tr{
	border-top:1px solid #333;
}
.problem-tables tr td{
	text-align: center;
	height:45px;
	line-height:45px;
	font-size:14px;

}

.problem-tables tr td:nth-child(2),
.problem-tables tr td:nth-child(4),
.problem-tables tr td:nth-child(6){
	border-left:1px solid #333;
	border-right:1px solid #333;
}
.problem-tables tr td:nth-child(7){border-left:1px solid #333;}

.problem-tables tbody tr:nth-child(odd){
	background:#fff;
}
.problem-tables tbody tr:nth-child(even){
	background:#d7d7d7;
}
</style>
</head>
<body>
    <header id="header" class="relative full-x"></header>

    <div class="allwarp relative">

        <div class="main-Content">
        	<div class="search-cont bg-fff mt-20">
        		<!--<label class="ml-20">课程:</label><input type="text" class="search-intxt rad-3"/>-->
        		<label>题目:</label><input type="text" class="search-intxt rad-3" id="questionTitle"/>
        		<label>类型:</label>
        		<select class="search-intxt rad-3" id="questionType">
					<option value="">ALL</option>
					<option value="1">填空题</option>
					<option value="2">选择题</option>
					<option value="3">判断题</option>
					<option value="4">程序填空题</option>
					<option value="5">程序改错题</option>
					<option value="6">编程题</option>
				</select>
        		<!--<label>编号:</label>
        		<input type="text" class="search-intxt rad-3"/>-->
        		<a href="javascript:;" class="search-btn rad-3 text-center f-14 c-fff ml-20" onclick="searchProblemFun(1)">go</a>
        	</div>
            <div class="common-cont problem-area mt-10 full-x bg-fff">
            	<table class="problem-tables">
            		<thead>
						<tr>
							<td>id</td>
							<!-- <td>状态</td>
							<td>章节</td> -->
							<td>标题</td>
							<td>类型</td>
							<td>难度</td>
							<td>通过率</td>
						</tr>
					</thead>
					<tbody id="questTabs"></tbody>
				</table>
				<div class="paging-area-box mt-10 magin-auto">
					<div class="paging-area float-left" id="pagination"></div>
					<span class="pageNum float-right f-14">共<em>0</em>条数据</span>
				</div>
            </div>
        </div>
    </div>
    <footer id="footer" class="full-x f-14 c-666 text-center"></footer>
</body>
<script src="../../static/js/util/jquery-1.9.1.min.js"></script>
<script src="../../static/js/util/bootstrap.min.js"></script>
<script src="../../static/js/util/jquery.paging.min.js"></script>
<script src="../../static/js/commonJS/interface.js"></script>
<script src="../../static/js/commonJS/common.js"></script>
<script>
	function tableListFun(pageNo){
        var id = window.document.getElementById("questTabs");

        $.ajax({
            url: get_questionAll_interface+'?currentPage='+pageNo,
            type:'post',
            dataType:'json',
			xhrFields:{
				withCredentials:true
			},
			crossDomain:true,
			data:{
                currentPage:pageNo
			},
            success: function(data) {
                if(data.code==601){
                    innerTbody(data,id, tableListFun);
                }else{
                    $.message(data.msg);
                }
            },
            error: function (error) {
                $.message("链接超时，请刷新...");
            }
        });
    }


    function searchProblemFun(pageNo){
		var questionTitle = $("#questionTitle").val();
		var questionType = $("#questionType").val();

        var id = window.document.getElementById("questTabs");

        if(questionType!=""){
        	questionType=parseInt(questionType)
        }

        $.ajax({
            url: search_questionAll_interface+"?currentPage="+pageNo,
            type:'post',
            dataType:'json',
			contentType:"application/json",
			xhrFields:{
				withCredentials:true
			},
			crossDomain:true,
            data:JSON.stringify({
                questionTitle:questionTitle,
				questionType:questionType
            }),
            success: function(data) {
                if(data.code==200){
                	//对后端传回数据进行修整
					for(var i=0;i<data.data.list.length;i++){
						data.data.list[i].questionId=data.data.list[i].problemId;
						data.data.list[i].questionTitle=data.data.list[i].problemTitle;
						data.data.list[i].questionDifficulty=data.data.list[i].problemDifficulty;
					}
                    innerTbody(data,id, searchProblemFun);
                }else{
                    $.message(data.msg);
                }
            },
            error: function (error) {
                $.message("链接超时，请刷新...");
            }
        });
	}

    tableListFun(1);

    function innerTbody(data,id, func){
        var page = data.data.num;
        var currentPage = data.data.currentPage;
        var tml = "";

        $(".pageNum em").html(page);
        if(page>0){
            setPagination(page,currentPage, func);
            var list = data.data.list;
            $('#pagination').show();
            for (x in list) {
                tml += "<tr>"+
                    '<td>'+list[x]["questionId"]+'</td>' +
					/*'<td></td>' +
                    '<td></td>' +*/
                    '<td>'+list[x]["questionTitle"]+'</td>' +
                    '<td>'+list[x]["questionType"]+'</td>' +
                    '<td>'+list[x]["questionDifficulty"]+'</td>' +
                    '<td>'+list[x]["passPercent"]+'</td>' +
                    "</tr>" ;
            }
        }else{
            $('#pagination').hide();
        }
        id.innerHTML = tml;
    }

</script>
</html>